/* 百度地图》路况 */
export default function loadTrafficControl(ak) {
    return new Promise(function(resolve, reject) {
      if (typeof BMapLib !== 'undefined') {
        resolve(BMapLib)
        return true
      }
      let style = document.createElement('link')
      style.type = 'text/css'
      style.href = '//api.map.baidu.com/library/TrafficControl/1.4/src/TrafficControl_min.css'
      style.rel = 'stylesheet'
      // style.onerror = reject
      document.head.appendChild(style)
      
      let script = document.createElement('script')
      script.type = 'text/javascript'
      script.src = '//api.map.baidu.com/library/TrafficControl/1.4/src/TrafficControl_min.js'
      // script.onerror = reject
      /* script.onload = script.onreadystatechange = function() {
          if (!this.readyState || this.readyState === "loaded" || this.readyState === "complete" ) {
            resolve(BMapLib)
              script.onload = script.onreadystatechange = null;
          }
      } */
      document.head.appendChild(script)
    })
  }
  